| Conditions | 1 |
| Paths | 1 |
| Total Lines | 63 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | describe('Rest Proxy in Model', function() { |
||
| 106 | it('should save existing entity with existing belongTo association', function() { |
||
| 107 | var car = Ext.create('Test.TestBundle.Entity.Car', { |
||
| 108 | name: 'Ford', |
||
| 109 | plateNumber: 'AA1234', |
||
| 110 | password: 'xx' |
||
| 111 | }); |
||
| 112 | var runned = false; |
||
| 113 | var car_owner_id; |
||
| 114 | runs(function() { |
||
| 115 | car.save({ |
||
| 116 | callback: function(record) { |
||
| 117 | var owner = Ext.create('Test.TestBundle.Entity.CarOwner', { |
||
| 118 | name: 'James Y' |
||
| 119 | }); |
||
| 120 | owner.save({ |
||
| 121 | callback: function(record) { |
||
| 122 | car.setCarOwner(record, { |
||
| 123 | callback: function() { |
||
| 124 | runned = true; |
||
| 125 | car_owner_id = car.get('car_owner_id'); |
||
| 126 | } |
||
| 127 | }); |
||
| 128 | } |
||
| 129 | }); |
||
| 130 | } |
||
| 131 | }); |
||
| 132 | }); |
||
| 133 | waitsFor(function() { |
||
| 134 | return runned; |
||
| 135 | }); |
||
| 136 | |||
| 137 | // Reload Car entity from REST proxy. Car_owner_id should still be there. |
||
| 138 | var runned1 = false; |
||
| 139 | runs(function() { |
||
| 140 | Test.TestBundle.Entity.Car.load(car.get('id'), { |
||
| 141 | callback: function(record) { |
||
| 142 | record.set('name', 'Audi'); |
||
| 143 | |||
| 144 | // Save and reload again. If car_owner_id was not there the belongsTo association is destroyed. |
||
| 145 | record.save({ |
||
| 146 | callback: function(record) { |
||
| 147 | Test.TestBundle.Entity.Car.load(car.get('id'), { |
||
| 148 | callback: function(record) { |
||
| 149 | car = record; |
||
| 150 | runned1 = true; |
||
| 151 | } |
||
| 152 | }); |
||
| 153 | } |
||
| 154 | }); |
||
| 155 | } |
||
| 156 | }); |
||
| 157 | }); |
||
| 158 | waitsFor(function() { |
||
| 159 | return runned1; |
||
| 160 | }); |
||
| 161 | |||
| 162 | runs(function() { |
||
| 163 | expect(car.getCarOwner()).not.toBeNull(); |
||
| 164 | expect(car.get('car_owner_id')).toBe(car_owner_id); |
||
| 165 | expect(car.getCarOwner().get('name')).toBe('James Y'); |
||
| 166 | expect(car.get('name')).toBe('Audi'); |
||
| 167 | }); |
||
| 168 | }); |
||
| 169 | it('should update entity', function() { |
||
| 289 | }); |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.